package com.xywy.me;

import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.xywy.R;
import com.xywy.common.BaseActivity;
import com.xywy.common.widget.TitleBar2;

/**
 * 服务协议
 * @author xiaogd
 *
 */
public class SetupAboutServiceActivity extends BaseActivity  {
    private static final String  TAG = "SetupAboutServiceActivity";
    private WebView webView;
    private ProgressBar pb;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        //设置为全屏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.me_setup_about_service);

        initView();

    }
    @Override
    public void initView(){
        //title
        TitleBar2 titleBar = (TitleBar2)findViewById(R.id.find_about_service_title_bar);
        TextView tvTitle = titleBar.getTitle();
        TextView tvBack =  titleBar.getTvBack();
        titleBar.getGo().setVisibility(View.INVISIBLE);
        titleBar.onClickBack(this);
        tvTitle.setText(getString(R.string.me_setup_about_service));
        tvBack.setText(getString(R.string.me_setup_title));


        pb = (ProgressBar) findViewById(R.id.pb_me_setup_about_service);
        pb.setMax(100);

        webView = (WebView) findViewById(R.id.wv_me_adout_service);

        webView.getSettings().setJavaScriptEnabled(true); // 设置支持javascript的例子

        // 通过WebChromeClient可以处理JS对话框，titles, 进度，等 ，这个例子，我们处理
        // ，我们将websit下载的进度同步到acitity的进度条上。
        webView.getSettings().setJavaScriptEnabled(true);   //设置支持Javascript
        webView.getSettings().setBuiltInZoomControls(true);   //页面添加缩放按钮
        webView.getSettings().setSupportZoom(true);
        webView.setWebChromeClient(new WebViewClient() );
        webView.requestFocus();   //触摸焦点起作用.如果不设置，则在点击网页文本输入框时，不能弹出软键盘及不响应其他的一些事件。
        webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);   //取消滚动条
        webView.loadUrl(getString(R.string.me_webview_about_service));
    }


    @Override
    public void preInit() {

    }

    @Override
    public void loadData() {

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        this.finish();
    }

    private class WebViewClient extends WebChromeClient {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            pb.setProgress(newProgress);
            if(newProgress==100){
                pb.setVisibility(View.GONE);
            }
            super.onProgressChanged(view, newProgress);
        }

    }
}



